package foundation;

import java.sql.Connection;
import java.sql.Statement;

public class FWrite {

	private static FWrite write = new FWrite();

	public synchronized static FWrite getInstance(){
		return write;
	}
	/**
	 * @author kasper
	 */
	public FWrite(){

	}

	/**This method stores an position object into the database
	 */
	public void dematerializePosition(Connection con, long time, float longitude, float latitude, String status, int taxiID){
		try{
			Statement stmt = con.createStatement();
			stmt.executeUpdate("INSERT INTO taxipositions(time, longitude, latitude, status, taxiID) VALUES("+time+", "+ longitude+","+ 
					latitude+", '"+status+"',"+taxiID+")");
			//	System.out.println("Gemte objektet: " + aPosition);
		} catch( Exception e ) {
			System.out.println("There was a problem dematerializing the object");
			e.printStackTrace();
		}//end catch
	}
	public void dematerializeOrder(Connection con, String address, String city, String zipCode, String phone, int orderID, long ordertime) {
		try{
			Statement stmt = con.createStatement();
			stmt.executeUpdate("INSERT INTO orders(orderID, address, city, zipCode, phone, ordertime) VALUES("+orderID+",'"+address+ "','" + city + "','" + zipCode + "','" + phone + "',"+ordertime+")");
			//	System.out.println("Gemte objectet: " + aPosition);

		} catch( Exception e ) {
			System.out.println("There was a problem dematerializing the object");
			e.printStackTrace();
		}//end catch
	}
		
}